import { uniqueId } from 'lodash'
// import header from '@/menu/header'
// import aside from '@/menu/aside'

// import demo from '@/menu/modules/demo'
// import marketing from '@/menu/modules/marketing'
import announce from '@/menu/modules/announce'
import volunteer from '@/menu/modules/volunteer'
import blood from '@/menu/modules/blood'
import repository from '@/menu/modules/repository'
import user from '@/menu/modules/user'
// const adminList = require('@/store/modules/d2admin/modules/account')
/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
const superAdmin = [announce, volunteer, blood, repository, user]
const reposAdmin = [blood, repository]
const bloodAdmin = [blood, volunteer]
let adminList = []
function supplementPath (menu) {
  const role = window.localStorage.getItem('role')
  if (role == 0) {
    adminList = superAdmin
  } else if (role == 1) {
    adminList = reposAdmin
  } else if (role == 2) {
    adminList = bloodAdmin
  }
  // console.log('adminList', adminList)
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId('d2-menu-empty-'),
    ...e.children ? {
      children: supplementPath(e.children)
    } : {}
  }))
}

// 菜单 侧边栏
export const menuAside = supplementPath(adminList)

// 菜单 顶栏
export const menuHeader = supplementPath([
  {
    path: '/index',
    title: '首页',
    icon: 'home'
  },
  ...adminList
])

// export const menuHeader = supplementPath(header)

// export const menuAside = supplementPath(aside)
